﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using YAPACS.RisServer.Abstractions;
using YAPACS.RisServer.Services.Dtos;
using YAPACS.Workflows;

namespace YAPACS.RisServer.Controllers;
[Authorize]
public class ExamApplyController : AbpControllerBase
{
    private readonly IExamApplyService _examApplyService;

    public ExamApplyController(IExamApplyService examApplyService)
    {
        _examApplyService = examApplyService;
    }

    /// <summary>
    /// 获取检查申请高级搜索视图
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Route("api/exam-apply/get-advanced-search-view")]
    public async Task<IActionResult> GetExamApplyAdvancedSearchView()
    {
        var result = await _examApplyService.GetAdvancedSearchViewAsync();
        return Ok(result);

    }
    /// <summary>
    /// 获取检查申请列表
    /// </summary>
    /// <param name="interfaceService"></param>
    /// <param name="number"></param>
    /// <returns></returns>
    [HttpPost]
    [Route("api/exam-apply/get-interface-service-list-{interfaceServiceId}")]
    public async Task<IActionResult> GetExamApplyItems(Guid interfaceServiceId, [FromQuery] string number, [FromBody] DataGridRequest request)
    {
        var result = await _examApplyService.GetExamApplyItemsAsync(interfaceServiceId,number, request);
        return Ok(result);
    }
    /// <summary>
    /// 添加检查
    /// </summary>
    /// <returns></returns>
    [HttpPost("api/exam-apply/add-exam/{interfaceServiceId}")]
    public async Task<IActionResult> AddExamAsync(Guid interfaceServiceId,[FromBody] List<string> examItemNumbers)
    {
        var result = await _examApplyService.AddExamAsync(interfaceServiceId, examItemNumbers);
        return Ok(result);
    }
    [HttpPost("api/exam-apply/supplementary-exam/{interfaceServiceId}")]
    public async Task<IActionResult> Supplementary(Guid interfaceServiceId, [FromForm] Guid examId, [FromForm] IList<string> examItemNumbers)
    {
        var result = await _examApplyService.SupplementaryAsync(interfaceServiceId, examId, examItemNumbers);
        return Ok(result);
    }
    [HttpPost("api/exam-apply/get-supplementary-view")]
    public async Task<IActionResult> GetSupplementaryVerifyView([FromBody] WorkflowInput input)
    {
        var result = await _examApplyService.GetSupplementaryVerifyViewAsync(input, "/api/exam-apply/get-supplementary-view");
        return Ok(result);
    }
}
